import 'package:flutter/material.dart';

class LoadingOverlay extends StatelessWidget {
  final Widget child;
  final bool isLoading;
  bool isHidden;

  LoadingOverlay({
     this.child,
    this.isLoading,
    bool isHidden = false
  }) : this.isHidden = isHidden;

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        child,
        if (isLoading)
          Positioned.fill(
            child: Container(
              color: Colors.white70,
              child: Center(
                child: isHidden ? Container() : CircularProgressIndicator(),
              ),
            ),
          ),
      ],
    );
  }
}

class LoadingOverlay1 extends StatelessWidget {
  final bool isLoading;
  final double progress;

  LoadingOverlay1({this.isLoading, this.progress});

  @override
  Widget build(BuildContext context) {
    return isLoading
        ? IgnorePointer(
          ignoring: true,
          child: Stack(
      children: <Widget>[
          Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                CircularProgressIndicator(
                  value: progress,
                  backgroundColor: Colors.white,
                  valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
                ),
                SizedBox(height: 16.0),
                Text('${(progress * 100).toInt()}%'),
              ],
            ),
          ),
      ],
    ),
        )
        : Container();
  }
}